package novel.common.test;

import java.util.concurrent.BlockingQueue;

/**
 * Created by sutong on 2017/10/24.
 */
public class ConsumerQueue implements Runnable {
    private final BlockingQueue queue;
    public ConsumerQueue(BlockingQueue queue){
        this.queue=queue;
    }
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                System.out.println("消费者消费的苹果编号为："+queue.take());
//                Thread.sleep(3000);  //在这里sleep是为了看的更加清楚些
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
